<template>
	<view class="index">
		<view class="navbar">
			<view class="notice have">
				<tn-icon icon="notice" size="60"></tn-icon>
			</view>
			<view class="search-bar">
				<uni-search-bar 
					@confirm="search" 
					:focus="true" 
					v-model="searchValue"
					placeholder="搜索你感兴趣的工作"
				>
				</uni-search-bar>
				<!-- <view class="search-result">
					<text class="search-result-text">当前输入为：{{ searchValue }}</text>
				</view> -->
			</view>
		</view>
		<view class="filtrate">
			<view class="filtrate-item">
				<uni-data-select
					v-model="comprehensiveValue" 
					:localdata="comprehensiveScreeningConditions" 
					@change="selectComprehensiveHandler"
					:clear="false"
					id="comprehensiveScreening">
				</uni-data-select>
			</view>
			<view class="fitrate-item">
				<uni-data-select
					placeholder="工作时长"
					v-model="durationVaue" 
					:localdata="durationScreeningConditions" 
					@change="selectDurationHandler"
					:clear="false"
					id="comprehensiveScreening">
				</uni-data-select>
			</view>
			<view class="filtrate-item">
				<uni-data-select
					placeholder="报酬"
					v-model="rewardValue" 
					:localdata="rewardScreeningConditions" 
					@change="selectRewardHandler"
					:clear="false"
					id="comprehensiveScreening">
				</uni-data-select>
			</view>
			<view class="filtrate-item">
				<uni-data-select
					placeholder="位置距离"
					v-model="distanceValue" 
					:localdata="distanceScreeningConditions" 
					@change="selectDistanceHandler"
					:clear="false"
					id="comprehensiveScreening">
				</uni-data-select>
			</view>
		</view>
		<view class="task-ul">
			<ul>
				<li v-for="(task,index) in tasks" :key="task.name">
					<rough-task-presentation :task="task"/>
				</li>
			</ul>
		</view>
	</view>
</template>

<script>
	import TnIcon from '@/uni_modules/tuniaoui-icon/components/tuniaoui-icon/tuniaoui-icon.vue'
	import RoughTaskPresentation from '@/components/RoughTaskPresentation/RoughTaskPresentation.vue'
	export default {
		components: {
			TnIcon,
			RoughTaskPresentation
		},
		data() {
			return {
				searchValue: '',
				comprehensiveValue: 0,
				durationVaue: "",
				rewardValue: "",
				distanceValue: "",
				comprehensiveScreeningConditions: [
					{value: 0, text: "综合排序"},
					{value: 1, text: "商家信用"}
				],
				durationScreeningConditions: [
					{value: 0, text: "一小时"},
					{value: 1, text: "二小时"},
				],
				rewardScreeningConditions: [
					{value: 0, text: "1k"},
					{value: 1, text: "2k"}
				],
				distanceScreeningConditions: [
					{value: 0, text: "1km以内"},
					{value: 1, text: "2km以内"}
				],
				tasks: [
					{
						avatarImgSrc: "",
						name: "吾面道",
						content: "急需洗碗工",
						duration: "五小时每晚",
						reward: 50,
						distance: "1km"
					},
					{
						avatarImgSrc: "",
						name: "吾面道",
						content: "急需洗碗工",
						duration: "五小时每晚",
						reward: 50,
						distance: "1km"
					},
					{
						avatarImgSrc: "",
						name: "吾面道",
						content: "急需洗碗工",
						duration: "五小时每晚",
						reward: 50,
						distance: "1km"
					},
					{
						avatarImgSrc: "",
						name: "吾面道",
						content: "急需洗碗工",
						duration: "五小时每晚",
						reward: 50,
						distance: "1km"
					}
				]
			}
		},
		methods: {
			search(res) {
				uni.showToast({
					title: '搜索：' + res.value,
					icon: 'none'
				})
			},
			selectComprehensiveHandler(value) {
				console.log(value);
			},
			selectDurationHandler(value) {
				console.log(value);
			},
			selectRewardHandler(value) {
				console.log(value);
			},
			selectDistanceHandler(value) {
				console.log(value);
			}
		},
		onBackPress() {
			// #ifdef APP-PLUS
			plus.key.hideSoftKeybord();
			// #endif
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	
	.index {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		
		.navbar {
			display: flex;
			justify-content: center;
			align-items: center;
			position: relative;
			width: 100%;
			height: 50px;
			
			.notice {
				width: 30px;
				position: absolute;
				left: 0;
				top: 20;
				margin-left: 10px;
				cursor: pointer;
				
				&.have::before {
					content: "";
					position: absolute;
					top: 0;
					left: -5px;
					width: 10px;
					height: 10px;
					background-color: red;
					border-radius: 50%;
				}
			}
		}
		
		.filtrate {
			display: flex;
			justify-content: space-between;
			align-items: center;
			gap: 10px;
			margin-top: 20px;
		}
		
		.task-ul {
			width: 100%;
		}
}
</style>
